/**************************************************************************************************
* Title: SumInputManager.inl
* Author: Gael Huber
* Description: Manager for all game input. Manages polling for input as well as updating input
*	values.
**************************************************************************************************/

/**************************************************************************************************
* Check whether a particular key is being pressed
**************************************************************************************************/
inline int InputManager::getKeyPressed(int code) const {
	return keyboard->getKeyPressed(code);
}

/**************************************************************************************************
* Get the mouse state
**************************************************************************************************/
inline const DIMOUSESTATE& InputManager::getMouseState(void) const {
	return mouse->getMouseState();
}

/**************************************************************************************************
* Assign the proper function to a job, this gives a cleaner way of creating upper level engine jobs
**************************************************************************************************/
inline void AssignInputFunction(Job& job) {
	job = Job(&InputManager::kickPollInput, static_cast<void*>(InputManager::getSingletonPtr()));
	job.setStatus(Job::DONE);
}

/**************************************************************************************************
* Request input from the hardware
**************************************************************************************************/
inline void RequestInput(Job& job) {
	// Set the job status to pending
	job.setStatus(Job::PENDING);

	// Add the job to the queue
	JobManager::getSingletonPtr()->addJob(job);
}

/**************************************************************************************************
* Wait for input polling to finish
**************************************************************************************************/
inline void WaitForInput(Job& job) {
	while(job.getStatus() != Job::DONE)
		Sleep(THREAD_SLEEP_TIME);
}

/**************************************************************************************************
* Request a keyboard code to see whether it is currently pressed
**************************************************************************************************/
inline int GetKeyboardCode(int code) {
	return InputManager::getSingletonPtr()->getKeyPressed(code);
}

/**************************************************************************************************
* Returns the current mouse state
**************************************************************************************************/
inline const DIMOUSESTATE& GetMouseState(void) {
	return InputManager::getSingletonPtr()->getMouseState();
}